package com.ds.lens.data.vo.factory;

import com.ds.lens.data.vo.ResultVO;
import com.ds.lens.data.vo.enums.VoMessageEnum;
import com.ds.lens.data.vo.enums.VoStatusEnum;


/**
 * Description
 *
 * @author nianjun
 * @create 2017-08-23 下午4:05
 **/

public class ResultVoFactory {

    public static <T> ResultVO<T> getSuccessResultVo() {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setCode(VoMessageEnum.SUCCESS.getCode());
        resultVO.setStatus(VoStatusEnum.SUCCESS.getStatus());
        resultVO.setMessage(VoMessageEnum.SUCCESS.getMessage());

        return resultVO;
    }

    public static <T> ResultVO<T> getSuccessResultVo(T data) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setCode(VoMessageEnum.SUCCESS.getCode());
        resultVO.setStatus(VoStatusEnum.SUCCESS.getStatus());
        resultVO.setMessage(VoMessageEnum.SUCCESS.getMessage());
        resultVO.setData(data);

        return resultVO;
    }

    public static <T> ResultVO<T> getFailedResultVo() {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setCode(VoMessageEnum.FAILED.getCode());
        resultVO.setStatus(VoStatusEnum.FAILED.getStatus());
        resultVO.setMessage(VoMessageEnum.FAILED.getMessage());

        return resultVO;
    }

    public static <T> ResultVO<T> getFailedResultVo(VoMessageEnum voMessageEnum) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setStatus(VoStatusEnum.FAILED.getStatus());
        resultVO.setMessage(voMessageEnum.getMessage());
        resultVO.setCode(voMessageEnum.getCode());

        return resultVO;
    }

    public static <T> ResultVO<T> getFailedResultVo(VoMessageEnum voMessageEnum, String message) {
        ResultVO<T> resultVO = new ResultVO<T>();
        resultVO.setStatus(VoStatusEnum.FAILED.getStatus());
        resultVO.setMessage(message);
        resultVO.setCode(voMessageEnum.getCode());

        return resultVO;
    }

}
